<script setup>
import { useRouter } from 'vue-router';
const router = useRouter()
const props = defineProps({
    goodsList: {
        type: Array,
        default: () => []
    }
})
</script>

<template>
    <div class="goods_item" v-for="item in props.goodsList" :key="item.id">
        <a href="#" @click.prevent="router.push(`/detail/${item.id}`)">
            <!-- <img src=""> -->
             <el-image :src="item.image" lazy>
             </el-image>
            <!-- <img :src="item.image"> -->
            <span>￥<i>{{ item.price }}</i>.00</span>
            <span>剩余库存：{{ item.stock }}</span>
            <h2>{{ item.name }}</h2>
        </a>
    </div>
</template>

<style scoped lang="less">
    .goods_item {
        background-color: #fff;
        margin: 5px 5px;
        display: inline-block;
        width: 234px;
        height: 300px;
        padding: 10px 0;
        text-align: center;
        transition: all .3s;
        box-shadow: 2px 2px 2px rgba(0, 0, 0, .3);

        &:hover {
            transform: translateY(-5px);
        }

       .el-image,img {
            width: 160px;
            height: 160px;
        }

        span {
            display: inline-block;
        }

        :nth-child(2) {
            width: 100%;
            color: #e1251b;

            i {
                font-style: normal;
                font-size: 20px;
            }
        }

        :nth-child(3) {
            width: 100%;

            color: #666666;
            font-size: 12px;
        }

        h2 {
            font-size: 16px;
            color: #666666;
        }
    }
</style>
